<?php
/**
 * Ecga 应用类
 *
 * PHP version 5
 *
 * @package   Shop
 * @author    Weber Liu <weberliu@hotmail.com>
 * @copyright 2010 Xingchangxinda Inc.
 * @version   SVN: $Id: application.php 6798 2011-06-17 08:58:55Z liusijun $
 */

namespace Project\Apps\Ecga;

use \Framework\Application\HttpApplication;
use \Framework\System\Sessions;

define('NEW_ARCH', true);
require dirname(__FILE__) . '/library/common.php';
/**
 * Ecga 应用类
 *
 * @package   Shop
 * @author    Weberliu <weber.liu@gmail.com>
 * @copyright 2010 Xingchangxinda Inc.
 * @version   Release: 0.1
 */
class Application extends HttpApplication
{

    /**
     * 创建SESSION实例
     *
     * @return Sessions
     * @author Weber Liu
     */
    public function createSession()
    {
        static $sess = null;
        if ($sess == null) {
            $sess = new Sessions('Ecga');
        }
        return $sess;
    }

    /**
     * 解析url
     *
     * @param string $url 用户提交的url地址 
     *
     * @return array
     * @author Scott Ye
     */
    protected function parseUrl($url)
    {
        $parseParts = parse_url($url);
        $dirname = dirname($parseParts['path']);
        switch ($dirname) {
        case '/table':
            $pathInfo = pathinfo($parseParts['path']);
            $parseParts['path'] = '/table.php';
            $parseParts['query'] = sprintf(
                'table=%s&%s', $pathInfo['filename'],
                $parseParts['query']
            );
            break;
        }

        switch ($parseParts['path']) {
        case '/crossdomain.xml':
            $parseParts['path'] = '/crossdomain.php';
            break;
        case '/stat.gif':
            $parseParts['path'] = '/stat.php';
            break;
        }

        return $parseParts;
    }


}

